<?php
namespace Home\Controller;
use Think\Controller;
class LaborListController extends Controller{
    public function index(){
        $list=M('user_farmer')->select();
        foreach ($list as $k=>$v){
            $list[$k]['one']=$this->getOneList($v['uf_id'],'labor_skill','one');
            $list[$k]['two']=$this->getOneList($v['uf_id'],'working_experience','two');
            $list[$k]['three']=$this->getOneList($v['uf_id'],'training_experience','three');
            $list[$k]['four']=$this->getOneList($v['uf_id'],'current_workers','four');
            $list[$k]['five']=$this->getOneList($v['uf_id'],'employment_intention','five');
            $list[$k]['six']=$this->getOneList($v['uf_id'],'employment_time','six');
        }
        $this->assign("list",$list);
        $this->display();
    }
    public function getOneList($uf_id,$table,$type){
        switch ($type){
            case "one":$r="ls";break;
            case "two":$r="we";break;
            case "three":$r="te";break;
            case "four":$r="cw";break;
            case "five":$r="ei";break;
            case "six":$r="et";break;
        }
        //$str="shiyun_skill_type on shiyun_".$table.".".$r."_id="."shiyun_skill_type.st_id";
        $str=$r."_uf_id"."=$uf_id";
        $id=$r."_uf_id";
        $list=M($table)->where($str)->select();
        foreach ($list as $k=>$v){
            unset($v[$r.'_id']);
            unset($v[$r.'_uf_id']);
            foreach ($v as $v2){
                if($v2==0){
                    continue;
                }
                $list[$k]['name'][]=$this->getNameById($v2);
            }
        }
        return $list;
    }
    public function getNameById($id){
        $list= M('skill_type')->where("st_id=$id")->getField("st_name");
        return $list;
        
    }
}